
package com.amigo.online.provider.sync.convert.impl;

import org.bson.Document;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;
import com.amigo.online.provider.common.ConstantValue;
import com.amigo.online.provider.sync.abs.AbstractMongoConvertService;
import com.amigo.online.provider.sync.abs.ColumnHandleMap;
import com.amigo.online.provider.sync.convert.ConvertService;

/**
 * <code>MongoMerchantEntityConvertServiceImpl.java</code>
 * <p>
 *
 * </p>
 * <p>
 *
 * @author LuChen
 * @version 1.0
 * @company Amigo
 * @time 2019年1月31日 下午5:39:53
 * @lastUpdate 无
 * </p>
 */
@Service("mongoMerchantEntityConvertServiceImpl")
public class MongoMerchantEntityConvertServiceImpl extends AbstractMongoConvertService implements ConvertService<JSONObject, Document> {

    @Autowired
    ApplicationContext applicationContext;

    @Override
    public Document convert(JSONObject source, String tableName) {
        ColumnHandleMap handlerMap = (ColumnHandleMap) applicationContext.getBean(ConstantValue.SOURCE_MONGO + tableName);
        Document merchantDoc = new Document();
        CommonConvert(handlerMap, merchantDoc, source);
        merchantDoc.append("_class", "com.amigo.online.provider.merchant.mongo.entity.merchantEntity");
        return merchantDoc;
    }

}

